/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            refundDepositFeeInfo: {
                fees: [],
                total: 0,
                records: 1,
                moreCondition: false,
                roomId: '',
                ownerId: '',
                states:[{
                    name:'未退押金',
                    state:'1400',
                },{
                    name:'已退押金',
                    state:'1100',
                },
                {
                    name:'待审核',
                    state:'1000',
                },],
                state:'1400',
            }
        },
        _initMethod: function () {
            let _roomId = vc.getParam('roomId');
            let _ownerId = vc.getParam('ownerId');
            $that.refundDepositFeeInfo.roomId = _roomId;
            $that.refundDepositFeeInfo.ownerId = _ownerId;
            $that._switchDepositState($that.refundDepositFeeInfo.states[0]);
            
        },
        _initEvent: function () {
            vc.on('refundDepositFee', 'listFeeDeposit', function (_param) {
                $that._listFeeDeposit(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listFeeDeposit(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listFeeDeposit: function (_page, _rows) {
                let param = {
                    params: {
                        page: DEFAULT_PAGE,
                        row: DEFAULT_ROWS,
                        payerObjId: $that.refundDepositFeeInfo.roomId,
                        ownerId: $that.refundDepositFeeInfo.ownerId,
                        communityId: vc.getCurrentCommunity().communityId,
                        state:$that.refundDepositFeeInfo.state,
                    }
                };
                //发送get请求
                vc.http.apiGet('/fee.queryFeeDeposit',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        if(_json.code != 0){
                            return;
                        }
                        $that.refundDepositFeeInfo.total = _json.total;
                        $that.refundDepositFeeInfo.records = _json.records;
                        $that.refundDepositFeeInfo.fees = _json.data;
                        vc.emit('pagination', 'init', {
                            total: $that.refundDepositFeeInfo.records,
                            dataCount: $that.refundDepositFeeInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _queryFeeDepositMethod: function () {
                $that._listFeeDeposit(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if ($that.refundDepositFeeInfo.moreCondition) {
                    $that.refundDepositFeeInfo.moreCondition = false;
                } else {
                    $that.refundDepositFeeInfo.moreCondition = true;
                }
            },
            _switchDepositState:function(_state){
                $that.refundDepositFeeInfo.state = _state.state;
                $that._listFeeDeposit(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _toFeeDetail:function(_fee){
                vc.jumpToPage('/#/pages/property/propertyFee?feeId='+_fee.feeId);
            },
            _printRefundFeeReceipt:function(_fee){
                window.open('/#/pages/owner/ownerDetail?ownerId='+$that.refundDepositFeeInfo.ownerId+'&currentTab=ownerDetailReceipt')
            },
            _openRefundModel: function (_fee) {
                let _mainFeeInfo = {
                    feeId:_fee.feeId,
                    feeTypeCd:_fee.feeTypeCd,
                    configId:_fee.configId
                }
                _fee.mainFeeInfo = _mainFeeInfo;
                _fee.cycles = 1;
                _fee.receivableAmount = _fee.receivedAmount;
                vc.emit('returnPayFee', 'openReturnPayFeeModel', _fee);
            },
        }
    });
})(window.vc);